refactor: In alter_ty_path, return on failed unpack#1820
Conversation
| } | ||
|
|
||
| unpack!([&mut t.kind] TyKind::Path(qself, path)); | ||
| unpack!([&mut t.kind] TyKind::Path(qself, path); return); |
There was a problem hiding this comment.
Silencing errors isn't really the way to fix issues, let's investigate this.
Any idea why a type would appear as hir::TyKind::Path in the HIR, but as an Rptr in the AST? Maybe an alias? Could you print out which type this is?
There was a problem hiding this comment.
I printed out qpath when t.kind isn't TyKind::Path:
if !matches!(t.kind, TyKind::Path(..)) {
panic!("{qpath:?}");
}and got:
Resolved(
None,
Path {
span: Span {
lo: BytePos(129233),
hi: BytePos(129242),
ctxt: #57
},
res: PrimTy(
Bool
),
segments: [
PathSegment {
ident: bool#57,
hir_id: HirId {
owner: OwnerId {
def_id: DefId {
krate: crate0,
index: DefIndex(
50254
)
}
},
local_id: 25
},
res: PrimTy(
Bool
),
args: None,
infer_args: false
}
]
}
)So it's... bool? Not sure how to make sense of that one.
There was a problem hiding this comment.
Random thought: if the refactorer is making modifications to the AST, what happens to the HIR? Is it modified in parallel? If not, what keeps the two in sync? Could that be the issue here?
There was a problem hiding this comment.
The HIR is not preserved. The refactorer is expected to make independent modifications, or reload the crate if it makes changes that impact the HIR (and needs it to be correct).
derive(PartialEq, Eq)#1818This is a fix, but I don't know if it's actually the correct fix.